<template>
	<view class="confirm">
		<view class="top acea-row row-between">
			<view class="pictrue">
				<image :src="info.images[0]" mode=""></image>
			</view>
			<view class="title">
				{{ info.title }}
			</view>
		</view>
		
		<view class="text bgwhite p30">
			<view class="fs-30">智慧养老套装包含服务：</view> 
			<view class="content mt10">
				<block v-for="(item,index) in info.fuwuData" :key="index">
					<view>{{ item.title }}: {{ item.num }}{{ item.danwei }}</view>
				</block>
			</view>
		</view>
		
		<view class="info p30 bgwhite mt30">
			<view class="fs-40 bold">预约信息填写</view>
			<view class="acea-row row-between-wrapper bor-bot py30 fs-32">
				<view class="bold color333">姓名</view>
				<view>
					<input class="text-right color333" v-model="real_name" type="text" placeholder="请输入姓名" placeholder-class="color888"/>
				</view>
			</view>
			<view class="acea-row row-between-wrapper fs-32" style="padding-top: 30rpx;">
				<view class="bold color333">联系方式</view>
				<view>
					<input class="text-right color333" v-model="user_phone" type="number" maxlength="11" placeholder="请输入联系电话" placeholder-class="color888"/>
				</view>
			</view>
		</view>
		
		<view class="bgwhite p30 mt20">
			<view class="fs-34 color333 bold">您的地址</view>
			<textarea class="address" v-model="user_address" placeholder="请输入地址信息" placeholder-class="color333 fs-28"></textarea>
		</view>
		
		<view class="yuyue" @click="open">点击预约</view>
		
		<view style="width: 100%;height: 100rpx;"></view>
		
		<uni-popup ref="popup" type="center" :animation="true">
			<view class="box acea-row row-middle row-center row-column">
				<view class="title bold">您确定预约智慧养老套餐吗？</view>
				<view class="">
					<image class="tips-icon" src="https://yijiaan.oss-cn-hangzhou.aliyuncs.com/pic/tips-icon.png" mode="aspectFit"></image>
				</view>
				<view class="queding" @click="confrim">确定</view>
			</view>
		</uni-popup>
		
	</view>
</template>

<script>
	 import {
		 taocanDetails,
		 orderCreate
	 } from '@/api/admin.js'
	export default {
		data() {
			return {
				id:'',
				info:[],
				real_name:'',
				user_phone:'',
				user_address:'',
				loading: false,
			};
		},
		onLoad(option){
			this.id = option.id;
			this.getdetail();
		},
		methods:{
			getdetail(){
				taocanDetails({ id:this.id }).then(res=>{
					this.info = res.data.data
				})
			},
			confrim(){
				let that = this;
				let data = {
					real_name: that.real_name,
					user_phone: that.user_phone,
					user_address: that.user_address,
					id: that.id,
				}
				if( that.loading ) return;
				that.loading = true;
				orderCreate(data).then(res=>{
					that.$util.Tips({ title : res.msg },()=>{
						that.loading= false;
						uni.navigateTo({
							url: '/pages/reservation/status'
						})
					})
				}).catch(err=>{
					that.loading= false;
					return that.$util.Tips({ title : err })
				})
			},
			open(){
				let that = this;
				if( !that.real_name ) return that.$util.Tips({ title : '请填写姓名' })
				if( !that.user_phone ) return that.$util.Tips({ title : '请填写联系方式' })
				if( !that.user_address ) return that.$util.Tips({ title : '请填写详细地址' })
				this.$refs.popup.open();
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{ background-color: #f5f5f5 !important; }
	.confirm{
		
		.address{
			width: 630rpx;
			height: 180rpx;
			padding: 30rpx;
			background-color: #F5F5F5;
			border-radius: 10rpx;
			margin-top: 30rpx;
		}
		
		.top{
			width: 100%;
			padding: 30rpx;
			border-bottom: 1rpx solid #D8D8D8;
			background-color: #ffffff;
			
			.pictrue{
				width: 200rpx;
				height: 200rpx;
				border-radius: 10rpx;
				overflow: hidden;
				background-color: #000;
				
				image{
					width: 100%;
					height: 100%;
				}
			}
			.title{
				width: 460rpx;
				font-size: 40rpx;
				color: #333;
				font-weight: bold;
			}
		}
		
		.text{
			
			.content{
				line-height: 50rpx;
				font-size: 32rpx;
			}
		}
		
		.yuyue{
			width: 690rpx;
			height: 108rpx;
			border-radius: 96rpx;
			background: #FD7D36;
			margin: 50rpx auto 0 auto;
			text-align: center;
			line-height: 108rpx;
			color: #ffffff;
			font-size: 36rpx;
		}
		
		.box{
			width: 661rpx;
			height: 550rpx;
			border-radius: 20rpx;
			background-color: #ffffff;
			
			.title{
				color: #333333;
				font-size: 40rpx;
			}
			
			.tips-icon{
				width: 144rpx;
				height: 144rpx;
				margin: 30rpx 0;
			}
			
			.queding{
				width: 492rpx;
				height: 96rpx;
				border-radius: 96rpx;
				background: rgba(253, 125, 54, 0.3);
				text-align: center;
				line-height: 96rpx;
				color: #FD7D36;
				font-size: 36rpx;
				margin-top: 30rpx;
			}
			
		}
		
		
	}
</style>
